import pickle
from img2vec_pytorch import Img2Vec
from PIL import Image

# 1、加载已经训练好的模型
# model.kpl
with open('model.pkl', 'rb') as f:
    # 反序列化 恢复模型对象
    model = pickle.load(f)

img2vec = Img2Vec()
# 2 、定义待预测特征向量
image_path = './data/dataset/val/dogs/dog.10.jpg'
img = Image.open(image_path)

# 3、提取图像的特征向量
features = img2vec.get_vec(img)
# 使用加载的模型进行预测
pred = model.predict([features])

print(pred)
